
<html>
	
<script src="./js/axios.js"></script>	
<script>

//创建一个promise对象，初始状态为pedding状态

	let myaxios = {
		get:function(url){
			//发送异步请求,返回一个promise对象
			return new Promise(function(resolve,reject){
				let xhr = new XMLHttpRequest();
				xhr.open("GET",url);
				xhr.send();
				xhr.onreadystatechange=function(){
					if(xhr.status == 200 && xhr.readyState == 4){
						resolve(xhr.responseText);
					}
					if(xhr.status != 200){
						reject("完了完了");
					}
				}
			})
		}
	}

	myaxios.get("./data/1.json")
	.then(function(data){
		document.write(data);
		return myaxios.get("./data/2.json");
	})
	.then(function(data){
		document.write(data);
		return myaxios.get("./data/3.json");
	})
	.then(function(data){
		document.write(data);
	})
	
</script>
</html>